package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.query.StrategyCatalogQuery;
import cn.wolfcode.wolf2w.repository.StrategyRepository;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 区域控制器
 */
@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IStrategyCatalogService strategyCatalogService;

    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private ITravelService travelService;

    @GetMapping("hotRegion")
    public Object hotRegion(){
        List<Region> list = regionService.queryIshot();
        return JsonResult.success(list);
    }

    @GetMapping("search")
    public Object search(String regionId){
        List<Destination> list = destinationService.queryDestByRegionIdApi(regionId);
        return JsonResult.success(list);
    }

    @GetMapping("toasts")
    public Object toasts(String destId){
        List<Destination> list = destinationService.queryByParentId(destId);
        return JsonResult.success(list);
    }

    @GetMapping("detail")
    public Object detail(String id){
        return JsonResult.success(destinationService.selectById(id));
    }

    @GetMapping("catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> list = strategyCatalogService.queryDestId(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/strategies/viewnumTop3")
    public Object strategiesViewnumTop3(String destId){
        List<Strategy> strategyList = strategyService.queryViewmunTop3(destId);
        return JsonResult.success(strategyList);
    }

    @GetMapping("/travels/viewnumTop3")
    public Object travelsViewnumTop3(String destId){
        List<Travel> travelList = travelService.queryViewmunTop3(destId);
        return JsonResult.success(travelList);
    }

}
